package com.example.sqldemo.strategy;


import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class StrategyFactory {

    @Autowired
    private  final Map<String, Strategy> strategyMap = MapUtil.newHashMap(); // 方式一

    private Map<String, Strategy> map;

    public StrategyFactory(Map<String, Strategy> map) { // 方式二
        log.info("打印通过@Autowired注入的map: {} ", JSON.toJSONString(strategyMap));
        log.info("打印通过构造参数注入的 map : {} ", JSON.toJSONString(map));
        this.map = map;
    }

    public Map<String, Strategy> getStrategyMap() {
        return strategyMap;
    }

    public Map<String, Strategy> getMap() {
        return map;
    }
}
